package com.sunshine.boot;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 验证加载yml文件 <br />
 * yml文件中的每一行配置缩进不能用Tab键，要使用空格
 *
 * @author WeiHong
 * @date 2018/11/6
 */
@SpringBootApplication
public class TestYml {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = new SpringApplicationBuilder(TestYml.class)
                .properties(
                        "spring.config.location=classpath:config/application.yml")
                .run(args);
        System.out.println(context.getEnvironment().getProperty("jdbc.user"));
        System.out.println(context.getEnvironment().getProperty("jdbc.password"));
        System.out.println(context.getEnvironment().getProperty("jdbc.driver"));
    }
}
